package demo.api.trustsign;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import util.HttpClientUtil;

public class CertificateImport {
	private static String appKey = "cAwut4VATycNMq17NZeFUD63pe83l2OJ";
    private static String appSecrty = "3BAlrfr7lW8kwlCMfo1dXS8Syn5q5qjS";
    private static String baseUrl = "http://smp-test.szitrus.com.cn/smp-api";
    private static String api = "/api/trustsign/certificate/import";

	public static void main(String[] args) throws IOException {
		String url = baseUrl.concat(api);
	    // 请求参数
		Map<String, String> params = new HashMap<>();
	    params.put("user_id", "2"); 
	  //cert_encoded和pkcs12二选一
        params.put("cert_encoded", "");//base64，证书请求，PKCS#10格式 Base64 编码数据 //-----BEGIN CERTIFICATE REQUEST-----。。。-----END CERTIFICATE REQUEST-----					
        params.put("pkcs12", "");// 带私钥及数字证书的格式， Base64编码数据
        params.put("password", "");//私钥保护密码，通过该密码访问 PKCS#12
        params.put("is_default", "yes");//yes/no //是否设置为当前用户的默认证书 

	    String resStr =  HttpClientUtil.getResponse(url, params, appKey, appSecrty);
	    JSONObject resJson = JSON.parseObject(resStr);	
	    System.out.println(resJson);
	}
}
